package com.test.clyq.entity;

import org.dom4j.Document;
import org.dom4j.DocumentHelper;
import org.dom4j.Element;

import com.test.entity.Item;
import com.test.json.JsonUtil;

/**
 * 数据权限. <br>
 * 数据权限实体.
 * <p>
 * Copyright: Copyright (c) 2010-4-17 下午04:58:35
 * <p>
 * Company: 北京宽连十方数字技术有限公司
 * <p>
 * Author: liuxl@c-platform.com
 * <p>
 * Version: 1.0
 * <p>
 */
public class DataPermission implements Item {

	private static final long serialVersionUID = 1186047164500L;

	/** 数据权限ID */
	private Long dataPermissionId;

	private Long datePermissionCategoryId;

	private Long datePermissionUserId;

	public Long getDataPermissionId() {
		return dataPermissionId;
	}

	public Long getDatePermissionCategoryId() {
		return datePermissionCategoryId;
	}

	public Long getDatePermissionUserId() {
		return datePermissionUserId;
	}

	@Override
	public Long getId() {
		return null;
	}

	public void setDataPermissionId(Long dataPermissionId) {
		this.dataPermissionId = dataPermissionId;
	}

	public void setDatePermissionCategoryId(Long datePermissionCategoryId) {
		this.datePermissionCategoryId = datePermissionCategoryId;
	}

	public void setDatePermissionUserId(Long datePermissionUserId) {
		this.datePermissionUserId = datePermissionUserId;
	}

	@Override
	public void setId(Long id) {

	}

	public String toJSON() {
		return JsonUtil.getJsonStringFromObject(this);

	}

	public String toXML() {
		Document doc = DocumentHelper.createDocument();
		Element root = doc.addElement("items");
		root.addElement("i").addAttribute("n", "主键").setText(String.valueOf(this.dataPermissionId != null ? this.dataPermissionId : ""));
		root.addElement("i").addAttribute("n", "用户ID").setText(String.valueOf(datePermissionUserId != null ? this.datePermissionUserId : ""));

		root.addElement("i").addAttribute("n", "栏目ID").setText(
		                                                       String.valueOf(this.datePermissionCategoryId != null ? this.datePermissionCategoryId
		                                                               : ""));

		return doc.asXML();
	}

}
